<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="/common/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<%@include file="/common/meta.jsp" %>
<title>预算科目</title>
<link href="${ctx}/scripts/jquery/treetable/master.css" rel="stylesheet" type="text/css" />
<link href="${ctx}/scripts/jquery/treetable/jquery.treeTable.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="${ctx}/scripts/jquery/jquery-1.3.2.js"></script>
<script type="text/javascript" src="${ctx}/scripts/jquery/ui/jquery-ui-1.7.1.js"></script>
<script type="text/javascript" src="${ctx}/scripts/jquery/treetable/jquery.treeTable.js"></script>

<script type="text/javascript">
	$(document).ready(function() {
		$("#mytreetable").treeTable();

		// Make visible that a row is clicked
		$("table#mytreetable tbody tr").mousedown(function() {
			$("tr.selected").removeClass("selected"); // Deselect currently selected rows
			$(this).addClass("selected");
		});

		// Make sure row is selected when span is clicked
		$("table#mytreetable tbody tr span").mousedown(function() {
			$($(this).parents("tr")[0]).trigger("mousedown");
		});
	});
</script>
</head>
<body>
<div class="x-panel-header">&nbsp;财务科目管理</div>
<div class="x-toolbar" style="height: 30px; padding: 5px 10px 0px 10px; border-bottom: 0px;">
<table width="100%">
  <tr>
    <td width="500">
      <input type="button" value="全部" class="button" onclick="oepnIndex('')"  style="font-weight: bold;">&nbsp;&nbsp;
      <s:iterator value="topItems" var="top">
	  	<input type="button" value="${top.name}" class="button" onclick="oepnIndex('${top.id}')" style="font-weight: bold; color: green;">&nbsp;&nbsp;
      </s:iterator>
    </td>
    <td style="font-size: 14px; font-weight: bold;">
      &nbsp;当前类别：
      <font color="red">
	      <s:if test="model.parent == null">全部</s:if>
    	  <s:else>${model.parent.name}</s:else>
      </font>
    </td>
    <td align="right">
      <a href="edit.do">
        <img src="${ctx}/images/icons/add.gif"><b>添加科目</b></a>&nbsp;&nbsp;
    </td>
  </tr>
</table>
</div>
  <table id="mytreetable" width="100%" align="center" >
	<thead>
 	  <tr>
	  	<th width="250">科目名称</th>
	  	<th width="150">预算编码</th>
		<th width="250">描述</th>
		<th width="150">操作</th>
	  </tr>
    </thead>
    <tbody>
      <s:iterator value="items" var="item">
      <tr id="${item.id}" class="${item.className}">
		<td width="250">${item.name}</td>
		<td width="150">${item.code}</td>
		<td width="250">${item.descn}</td>
		<td width="150">
		  <a href="edit.do?model.id=${item.id}" title="编辑科目"><img src="${ctx}/images/icons/modify.gif"></a>
		  &nbsp;&nbsp;
		  <s:if test="#attr.item.isLeaf == 1">
		  <a href="remove.do?model.id=${item.id}" title="删除科目"><img src="${ctx}/images/icons/delete.gif"></a>
		  </s:if>
		</td>
	  </tr>
	  </s:iterator>
	</tbody>
  </table>
  <script type="text/javascript">
    function oepnIndex(pid){
    	window.location.href = "index.do?model.parent.id=" + pid;
    }
  </script>
</body>
</html>